import { CpcBase, ICpcBaseIos } from "../base/CpcBase";

const ios: ICpcBaseIos = {
    inputs: [
        {
            name: "source",
            type: "Object",
            label: "输入",
        },
    ],
    outputs: [
        {
            name: "target",
            type: "Number",
            label: "输出字符串",
        },
    ],
};
export class ObjectToNumber extends CpcBase {
    public title = "取对象属性";

    public type = "GetStringByObject";

    public widget: any;

    protected codeEditDbShow = true;

    protected codeEidtReadOnly = true;

    public properties = {
        value: "",
    };

    constructor(title?: string) {
        super(ios, title);
        this.widget = this.addWidget("text", "prop.", "", this.setValue.bind(this));
    }

    public setValue(v: any): void {
        this.properties.value = v;
        if (this.widget) {
            this.widget.value = v;
        }
    }

    public onStart() {
        const inputData1 = this.getInputData(1);
        console.log("inputData1", inputData1);
    }

    cpcRunCode(preDatas: any[], inputInfos: any[], outputInfos: any[]): any[] {
        return [];
    }
}
